function accuracy = tCCAplot(static,yaw,pitch,Fs)
%---input---
%static：静止数据，第一个维度为session，第二个维度为stimulus，第三个维度为trial，第四个维度为channel，第五个维度为samplepoints
%yaw：偏航数据，数据格式同上
%pitch：俯仰数据，数据格式同上
stimulusFreq = [7.5 12.0];
epochLengths = 0.8:0.1:3.0;
stepTime = 0.2;


for i = 1:length(epochLengths)
    result = [];
    epochTime = epochLengths(i);
    for condition = 1:3
        switch condition
            case 1
                SSVEPdata = static;
            case 2
                SSVEPdata = yaw;
            case 3
                SSVEPdata = pitch;
        end
        for session = 1:size(SSVEPdata,1)
            refData = mean(SSVEPdata(session,[1 4],round(size(SSVEPdata,3)/2):end,:,:),[3,4]);
            refData = reshape(refData,2,[]);
            refData = normalize(refData,2);
            for stimulus = [1 4]
                for trial = 1:round(size(SSVEPdata,3)/2)
                    epoch = SSVEPdata(session,stimulus,trial,:,:);
                    %移除错误数据
                    if((session == 2) && (trial == 10) && (stimulus == 2) && (condition == 2))
                        epoch = SSVEPdata(session,stimulus,trial-1,:,:);
                    end
                    
                    epoch = reshape(epoch,size(SSVEPdata,4),size(SSVEPdata,5));
                    windowCount = floor((size(epoch,2) - epochTime * Fs + 1) / (stepTime * Fs));
                    for window = 1:windowCount
                        result(session,condition,stimulus,trial,window) = template_canonical_correlation_analysis(epoch(:,int32((window-1) * stepTime * Fs + 1):int32((window-1) * stepTime * Fs + epochTime * Fs)),...
                            refData(:,int32((window-1) * stepTime * Fs + 1):int32((window-1) * stepTime * Fs + epochTime * Fs))',stimulusFreq);
                        display(['epochLength: ', num2str(epochTime), ' Condition: ', num2str(condition), ' Stimulus: ', num2str(find([1 4] == stimulus)), 'Result: ', num2str(result(session,condition,stimulus,trial,window)),' Window: ', num2str(window)]);
                    end
                end
            end
        end
        %计算正确率
        for s = [1 4]
            accuracy(i,condition,s) = sum(result(:,condition,s,:,:) == (find([1 4] == s)), 'all') / (size(result,1) * size(result,4) * size(result,5) / 2) * 100;
        end
    end
end

acc = mean(accuracy,3);
acc = reshape(acc,[],3);
figure;
for c = 1:3
    plot(epochLengths,acc(:,c),'linewidth',2);
    hold on;
end
xlabel('Epoch Length [s]');
ylabel('Accuracy %');
legend('Static','Yaw','Pitch');
set(gca, 'linewidth', 2, 'fontsize', 20, 'fontname', 'times');


end

